package com.easylinkin.linkappapi.positioning.controller;

import com.easylinkin.linkappapi.positioning.entity.MonitorMapDevice;
import com.easylinkin.linkappapi.positioning.entity.MonitorMapStatistics;
import com.easylinkin.linkappapi.positioning.entity.QueryMonitorMap;
import com.easylinkin.linkappapi.positioning.service.MonitorMapService;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;
import java.util.List;

/**
 * class info :重庆定位监控--监控地图
 *
 * @author liuqihang
 * @date 2021/6/25 15:35
 */
@RestController
@RequestMapping("/position/map")
public class MonitorMapController {

    @Resource
    private MonitorMapService monitorMapService;

    @PostMapping("getStatistics")
    public RestMessage getStatisticsInfo(@RequestBody QueryMonitorMap queryMonitorMap) {
        Assert.notNull(queryMonitorMap, "queryMonitorMap 不能为空");
        Assert.notNull(queryMonitorMap.getFunctionIdentifier(), "功能识别码不能为空");
        MonitorMapStatistics statisticsInfo = monitorMapService.getStatisticsInfo(queryMonitorMap);
        return RestBuilders.successBuilder().data(statisticsInfo).build();
    }

    @PostMapping("getDeviceList")
    public RestMessage getDeviceList(@RequestBody QueryMonitorMap queryMonitorMap) {
        Assert.notNull(queryMonitorMap, "queryMonitorMap 不能为空");
        Assert.notNull(queryMonitorMap.getFunctionIdentifier(), "功能识别码不能为空");
        List<MonitorMapDevice> deviceList = monitorMapService.getDeviceList(queryMonitorMap);
        return RestBuilders.successBuilder().data(deviceList).build();
    }
}
